package com.supermap.dataservice.cloud.market;

import com.alibaba.dubbo.config.annotation.Service;
import com.supermap.dataservice.mysql.config.DynamicDataSourceContextHolder;
import com.supermap.dataservice.util.JSONUtil;
import com.supermap.dubbo.api.cloud.market.MarketinfoService;

import javax.annotation.Resource;

/**
 * @author aqua
 * @description
 * @date 2018年11月22 下午 9:50
 * @email 1301584033@qq.com
 */
@Service
public class MarketinfoServiceImple implements MarketinfoService {

    @Resource
    private MarketinfoMapper marketinfoMapper;

    @Override
    public JSONUtil getAllArea() {
        DynamicDataSourceContextHolder.setDataSourceKey("ds2");
        return new JSONUtil().setData(marketinfoMapper.getAllArea());
    }

    @Override
    public JSONUtil getAllMarktNameByAreaCode(String areaCode) {
        DynamicDataSourceContextHolder.setDataSourceKey("ds1");
        return new JSONUtil().setData(marketinfoMapper.getAllMarktNameByAreaCode(areaCode));
    }

    @Override
    public JSONUtil getLastOntDay(String areaCode, String cropstype,String marketname) {
        DynamicDataSourceContextHolder.setDataSourceKey("ds1");
        return new JSONUtil().setData(marketinfoMapper.getLastOntDay(areaCode,cropstype,marketname));
    }

    @Override
    public JSONUtil getLastSevenDay(String areaCode, String code,String marketname) {
        DynamicDataSourceContextHolder.setDataSourceKey("ds1");
        return new JSONUtil().setData(marketinfoMapper.getLastSevenDay(areaCode,code,marketname));
    }

    @Override
    public JSONUtil getMarketTitle() {
        DynamicDataSourceContextHolder.setDataSourceKey("ds2");
        return new JSONUtil().setData(marketinfoMapper.getMarketTitle());
    }

    @Override
    public JSONUtil getlatelyFirstMarketinfo(String marketTitle) {
        DynamicDataSourceContextHolder.setDataSourceKey("ds2");
        return new JSONUtil().setData(marketinfoMapper.getlatelyFirstMarketinfo(marketTitle));
    }

    @Override
    public JSONUtil getlatelyTop7Market(String marketTitle, String goods) {
        DynamicDataSourceContextHolder.setDataSourceKey("ds2");
        return new JSONUtil().setData(marketinfoMapper.getlatelyTop7Market(marketTitle,goods));
    }
}
